import http, {HttpOptions} from "../http"

// 响应接口
export interface GetUserPostByNoPublicRes {
    code: number;
    msg: string;
    data: {
        total: number;
        size: number;
        current: number;
        records: {
            id: number;
            avatar: string;
            nickName: string;
            type: string;
            content: string;
            time: string;
            file: [{
                id: number;
                clientUrl: string;
                type: string;
            }],
            likeNum: number;
            likesId: Record<string, unknown>[];
            commentNum: number;
            message: string;
        }[];
    };
    timestamp: number;
    now: string;
}

/**
 * 审核员获取未发布的帖子列表
 * @param {string} page 页码
 * @param {string} size 每页数量
 * @returns
 */
export function getUserPostByNoPublic(page: number, size: number): Promise<GetUserPostByNoPublicRes> {
    const config:HttpOptions  = {
        msg: false,
        token: true,
        load: false,
    }
    return http.get(`/post/manage/userPost?page=${page}&size=${size}`, config);
}


// 参数接口
export interface PostSuccessParams {
    postId?: number;
    userId?: number;
    message?: string;
}

// 参数接口
export interface PostSuccessParams {
    postId?: number;
    userId?: number;
    message?: string;
    label?: string;
}

// 响应接口
export interface PostSuccessRes {
    code: number;
    msg: string;
    data: string;
    timestamp: number;
    now: string;
}

/**
 * 审核员通过
 * @param {object} params 帖子审核
 * @param {number} params.postId
 * @param {number} params.userId
 * @param {string} params.message
 * @param {string} params.label
 * @returns
 */
export function PostSuccess(params: PostSuccessParams): Promise<PostSuccessRes> {
    const config:HttpOptions  = {
        msg: false,
        token: true,
        load: false,
    }
    return http.post(`/post/manage/success`, params,config);
}

// 参数接口
export interface PostFailParams {
    postId?: number;
    userId?: number;
    message?: string;
    label?: string;
}

// 响应接口
export interface PostFailRes {
    code: number;
    msg: string;
    data: string;
    timestamp: number;
    now: string;
}

/**
 * 审核员不通过
 * @param {object} params 帖子审核
 * @param {number} params.postId
 * @param {number} params.userId
 * @param {string} params.message
 * @param {string} params.label
 * @returns
 */
export function PostFail(params: PostFailParams): Promise<PostFailRes> {
    const config:HttpOptions  = {
        msg: false,
        token: true,
        load: false,
    }
    return http.post(`/post/manage/fail`, params,config);
}